import { Router } from 'vue-router'
import { useAppStore } from '@/store'


export function createPageTitleGuard(router: Router): void {
  router.afterEach((to) => {
    const baseTitle = useAppStore().info.title;
    const pageTitle = to.meta?.title as string
    if (pageTitle) {
      document.title = `${pageTitle} | ${baseTitle}`
    } else {
      document.title = baseTitle
    }
  })
}
